package agile.tools.autotest;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import agile.tools.autotest.runner.IRecordedTestRunner;

public class MethodRecord {
	private String objectUnderTest;
	private String methodName;
	private List<String> serializedInputParams = new ArrayList<String>();
	private List<String> inputParamType = new ArrayList<String>();
	private String serializedReturnValue;
	private String returnValueType = "void";
	private String runner;

	public String runner() {
		return runner;
	}

	public void runner(String runner) {
		this.runner = runner;
	}

	public void objectUnderTest(String objectUnderTest) {
		this.objectUnderTest = StringUtils.strip(objectUnderTest);
	}

	public void methodName(String methodName) {
		this.methodName = StringUtils.strip(methodName);
	}

	public void serializedInputParam(String inputParam) {
		serializedInputParams.add(StringUtils.strip(inputParam));
	}
	
	public void serializedInputParam(String inputParam, String inputParamType) {
		serializedInputParam(inputParam);
		inputParamType(inputParamType);
	}

	public List<String> serializedInputParams() {
		return serializedInputParams;
	}

	public void inputParamType(String inputParam) {
		inputParamType.add(inputParam);
	}
	
	public void returnValueType(String returnValueType) {
		this.returnValueType = returnValueType;
	}
	
	public String returnValueType() {
		return this.returnValueType;
	}
	
	public List<String> inputParamTypes() {
		return inputParamType;
	}

	public Object serializedReturnValue(Object returnObj) {
		this.serializedReturnValue = StringUtils.strip((String) returnObj);
		return returnObj;
	}

	public Object serializedReturnValue() {
		return this.serializedReturnValue;
	}

	public String objectUnderTest() {
		return StringUtils.strip(this.objectUnderTest);
	}

	public String methodName() {
		return StringUtils.strip(this.methodName);
	}

	public List<String> getInputParams() {
		return serializedInputParams;
	}

	public String getOutput() {
		return serializedReturnValue;
	}

	public String inputParamTypesAsString() {
		StringBuffer sb = new StringBuffer();
		for (String type : inputParamType) {
			sb.append("_");
			sb.append(type);
		}
		return sb.toString();
	}
}